Add option for custom registries / mirrors #382
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Added support for custom, private registries in k3s, according to their documentation.
(Got inspired after getting rate limited by docker hub at work..)
As I've documented in the
sample/all.yml
comments, it could be useful if you're getting rate limited (for example by running your CI/CD jobs over and over in your cluster), or you're in an air-gapped environment where you don't have Internet access after the initial setup, or if you're bandwidth limited.If you've set up a private registry (for example using Sonatype Nexus, or Docker's Registry image, or Harbor),
to act as a "pull-through cache" as docker calls it, you can specify and override those docker.io / quay.io / ghcr.io endpoints with your own in
/etc/rancher/k3s/registries.yaml
.Doing that also allows you to use your actual private registry, the one that stores your images, without having to store registry credentials in a secret and using
imagePullSecrets
in your deployments.Of course you don't have to cache / proxy the docker.io / quay.io / ghcr.io images if you don't want / need to, you can just use this to add only your private registry.
I've tested both the caching and the private registry parts using my Harbor instance, works flawlessly.
Edit: I didn't add an "undo part" for the reset playbook, because the
/etc/rancher/k3s
dir gets cleaned up already.Checklist
site.yml
playbookreset.yml
playbook